package board_mvc.handler;

import java.util.HashMap;
import java.util.Map;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.servlet.ModelAndView;

import board.BoardDBBean;
import board.BoardDataBean;
@Controller
public class ModifyViewAction implements CommandHandler {
	@Resource( name="instance" )
	BoardDBBean dao;	
	@RequestMapping("/modifyView")
	@Override
	public ModelAndView process(HttpServletRequest request, HttpServletResponse response) {
		Map<String,Object>map=new HashMap<String, Object>();
		int num = Integer.parseInt( request.getParameter( "num" ) );
		int pageNum = Integer.parseInt( request.getParameter( "pageNum" ) );
		String passwd = request.getParameter( "passwd" );
		// BoardDBBean dao = BoardDBBean.getInstance();
		int result = dao.check( num, passwd );		
		if(result!=0){
			BoardDataBean dto = dao.getArticle( num );
			map.put("dto", dto);
		}
		map.put("num", num);
		map.put("pageNum", pageNum);
		map.put("result",result);
		return new ModelAndView("modifyView",map);
	}
}
